package com.lijian.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lijian.common.easyui.datagrid.EasyuiDataGridResult;
import com.lijian.common.utils.TaotaoResult;
import com.lijian.pojo.TbItem;
import com.lijian.service.ItemService;
@Controller
@RequestMapping("/item")
public class ItemController {

	@Autowired
	private ItemService itemService;
	
	@RequestMapping("/{itemId}")
	@ResponseBody
	public TbItem getItemById(@PathVariable Long itemId) {
		return itemService.getItemById(itemId);
	}
	
	@RequestMapping("/list")
	@ResponseBody
	public EasyuiDataGridResult getItemList(Integer page, Integer rows) {
		return itemService.getItemList(page, rows);
	}
	
	@RequestMapping("/save")
	@ResponseBody
	public TaotaoResult createItem(String desc,TbItem item,String itemParams){
		return itemService.createItem(item, desc,itemParams);
	}
	@RequestMapping("/item/{itemId}")
	public String showItemParam(@PathVariable Long itemId,Model model){
		model.addAttribute("myhtml", itemService.getItemParamHtml(itemId));
		return "itemparam";
	}
	
}
